<%@ page import="java.sql.*" %>
<%@ page import="com.nxcy.mysql.DBUtils" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    Object oname=session.getAttribute("name");
    if(oname==null){
        request.setAttribute("msg","请登录后查看");
        request.getRequestDispatcher("login.jsp").forward(request,response);
    }
    request.setCharacterEncoding("UTF-8");
    String id=request.getParameter("id");
    DBUtils db=new DBUtils();
    //4、创建sql语句（下达命令）

    //4008
    //4008,4009,4023

    String sql="DELETE FROM  t_user where id in ("+id+")";
    try{
        int count=db.executeUpdate(sql);
        if(count>0) {
            out.print("删除成功，2秒后跳转到首页");
            response.setHeader("refresh", "2;URL=index.jsp");
        }else{
            out.print("删除失败:没有找到该id的学生");
            response.setHeader("refresh","5;URL=index.jsp");
        }
    }catch (Exception e){
        out.print("删除失败："+e.getMessage());
        response.setHeader("refresh","5;URL=index.jsp");
    }finally {
        db.close();
    }
%>
